<?php

require_once( 'vo/SimpleObject.php' );

class Testservice
{
	/**
	 * 
	 * @param SimpleObject $object
	 * @return SimpleObject
	 */
	function createObject($object) {
		error_log(print_r($object,true));
		$object['name'] .= " COOL!";		
		return $object;
	}

	function saveproductAction() {

        $prod = new PapiWS_Model_PersonalizedProductVO();
        $prod->name = 'producto de prueba.';
        $prod->personalizedProductId = $personalizedProductId;
        $prod->faces = array();

        // levantamos el template 
        $tplService = new PapiWS_Service_ProductTemplate();
        $prod->templateProduct = $tplService->getInfo(10);

        // generamos las faces
        $f1 = new PapiWS_Model_PersonalizedFaceVO();
        $f1->faceOrder = 1;
        $f1->graphicalObjects = array();

        $f2 = new PapiWS_Model_PersonalizedFaceVO();
        $f2->faceOrder = 2;
        $f2->graphicalObjects = array();

        // agregamos un fondo a la primera cara
        $bg1 = new PapiWS_Model_BackgroundVO();
        $bg1->imageUrl = 'http://donline.ext.com.ar/sites/donline/files/gi4_0.jpg';
        $bg1->thumbnailUrl = 'http://donline.ext.com.ar/sites/donline/files/gi4.jpg';
        $bg1->type = PapiWS_Model_BackgroundVO::BACKGROUND_IMAGE;
        $bg1->x       = -180;
        $bg1->y       = -25;
        $bg1->width   = 266;
        $bg1->height  = 200;
        $bg1->fixedZ  = true;
        $f1->graphicalObjects[] = $bg1;

        // agregamos un fondo naranajaa la segunda cara
        $bg2 = new PapiWS_Model_BackgroundVO();
        $bg2->type = PapiWS_Model_BackgroundVO::BACKGROUND_FILL;
        $bg2->color = 0xff6600;
        $f2->graphicalObjects[] = $bg2;


        // agreguemos una shape a la parte de atrás
        $sh = new PapiWS_Model_ShapeVO();
        $sh->pngUrl = 'http://donline.ext.com.ar/sites/donline/files/icono5.png';
        $sh->swfUrl = 'http://donline.ext.com.ar/sites/donline/files/icono5.swf';
        $sh->svgUrl = 'http://donline.ext.com.ar/sites/donline/files/icono5.svg';
        $sh->x      = 50;
        $sh->y      = 60;
        $sh->z      = 1;
        $sh->width  = 128;
        $sh->height = 264;
        $f2->graphicalObjects[] = $sh;

        // agrego las dos caras
        $prod->faces[] = $f1;
        $prod->faces[] = $f2;

		$this->_helper->serverTester->xmlRpcClient( $this, 'saveProduct', array( $prod ) );
	}

	public function getXmlRpcUrl() 
	{
		return 'http://soa:8001/PapiWS/personalizedproduct/xmlrpc';
	}
}
